package com.yanq.liancar.activity;

import android.app.Dialog;
import android.content.Context;
import android.view.View;

import com.yanq.liancar.R;

public class ApkDialog implements View.OnClickListener {

    private Dialog dialog;
    private Context context;

    public ApkDialog(Context context) {
        this.context = context;
        if (dialog != null && dialog.isShowing()) {
            dialog.dismiss();
            dialog = null;
        }
        try {
            dialog = new Dialog(context, R.style.progress_dialog);
            dialog.setContentView(R.layout.dialog_apk);
            dialog.setCancelable(true);
            dialog.show();
            dialog.findViewById(R.id.bank_cancel).setOnClickListener(this);
            dialog.findViewById(R.id.bank_confirm).setOnClickListener(this);
        } catch (Exception e) {

        }
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.bank_cancel:
                dismissProgressDialog();
                break;
            case R.id.bank_confirm:
                ApkDown.start(context);
                dismissProgressDialog();
                break;
        }
    }

    private void dismissProgressDialog() {
        if (null != dialog && dialog.isShowing()) {
            dialog.dismiss();
            dialog = null;
        }
    }
}